package org.ricks.classfile;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class ProxyHandler implements InvocationHandler {
    private Object target;

    public ProxyHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        // 检查注解
        ProxyMethod annotation = method.getAnnotation(ProxyMethod.class);
        if (annotation != null) {
            System.out.println("拦截方法: " + method.getName() + "，注解参数: " + annotation.value());
        }
        return method.invoke(target, args);
    }
}
